<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <!--{include file='comm/header.tpl'}-->
    <!--{include file='comm/comm_cal.tpl'}-->
    <title>会员列表</title>
</head>
<body>

<div class="container">

    <div class="comm_content">

            <div class="search-box">
                <div style="position:relative">
                    <form id="search_form" class="form-inline" onsubmit="return false;">
                        <table>
                            <tbody>
                            <tr>
                                <td>会 员 名：<input type="text" id="custID" class="form-control input-sm w120"  name="custID" /></td>
                                <td>会员姓名：<input type="text" id="custname" class="form-control input-sm w120"  name="custname" /></td>
                                <td>会员等级：<select class="form-control input-sm" id="rankID" name="rankID">
                                        <option value="0">请选择</option>
                                        <!--{foreach from=$rank_array item=rank}-->
                                            <option value="<!--{$rank.rankID}-->"><!--{$rank.rankName}--></option>
                                        <!--{/foreach}-->
                                    </select>
                                </td>
                                <td>手机号：<input type="text" id="mobile" class="form-control input-sm w120" name="mobile" /></td>
                                <td>电   话：<input type="text" id="phone" class="form-control input-sm w150" name="phone" /></td>
                            </tr>
                            <tr>
                                <td>邮　箱：<input type="text" id="email" class="form-control input-sm w150" name="email" /></td>
                                <td colspan="2">
                                    注册日期：<input id="startDate" class="form-control input-sm w150" name="startDate" type='text' readonly="readonly" >
                                    ～
                                    <input id="endDate" class="form-control input-sm w150"  name="endDate" type='text' readonly="readonly" >
                                    <button type="button" class="btn btn-default btn-sm" onclick="customer.timeClear();">清 空</button>
                                </td>
                                <td colspan="4">
                                    &nbsp;
                                    <input type="button" value="查询" class="btn btn-primary" onclick="customer.search();" />&nbsp;&nbsp;
                                    <input type="button" value="重置" class="btn btn-warning" onclick="customer.reset();" />
                                </td>
                            </tr>
                            <tr>

                            </tr>
                            </tbody>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

</div>



<script type="text/javascript">
    $("#flex").flexigrid({
        url:"/invokingAjax-backend/customer/customer.ajax?operFlg=1",
        dataType: "json",
        colModel : [
            <!--{if $edit_permission}-->
            {display: "操作", width : 280, align: "center"},//mod by 20111104 allen.qiang FUN-BK-0019-手工重置会员密码
            {display: "使用状态", width : 80  , align: "center"},
            <!--{/if}-->
            {display: "会员号", name : "pcustID",align: "center", width : 80, sortable : true},
            {display: "会员名", width : 130},
            {display: "会员姓名", width : 80},
            {display: "会员等级", width : 60,align: "center"},
            {display: "累计消费金额", width : 80},
            {display: "会员来源", width : 60,align: "center"},
            {display: "会员类型", width : 60,align: "center"},
            {display: "手机是否验证", width : 90,align: "center"},
            {display: "省份", width : 80},
            {display: "城市", width : 80},
            {display: "地区", width : 80},
            {display: "地址", width : 230},
            {display: "email", width : 120},
            {display: "电话", width : 120},
            {display: "手机", width : 120},
            {display: "性别", width : 80,align: "center"},
            {display: "生日", width : 80,align: "center"},
            {display: "推荐人", width : 80,align: "center"},
            {display: "注册日期", width : 130,align: "center"}//add by allen.qiang 20150203
        ],
        <!--{if $edit_permission}-->
        buttons : [
            {name: "新增会员", bclass: "add", onpress : "customer.edit"}
        ],
        <!--{/if}-->
        sortname: "pcustID",
        sortorder: "desc",
        usepager: true,
        rp: 10,
        useRp: true,
        showTableToggleBtn: true,
        autoload: true,
        onSubmit: function() {
            var dt = $("#search_form").serializeArray();
            $("#flex").flexOptions({params: dt});
            return true;
        }
    });

    var customer = {

        pcustID:'',

        //搜索会员
        search: function() {
            var dt = $('#search_form').serializeArray();
            $("#flex").flexOptions({params: dt}).flexReload();
        },

        //重置
        reset: function() {
            document.getElementById('search_form').reset();
            this.search();
        },

        timeClear: function() {
            $('#startDate').val('');
            $('#endDate').val('');
        },

        //修改会员信息
        edit: function( pcustID ) {
            if (pcustID) {
                var url = "/quanliadmin/app/customer/customer.pscript?operFlg=3&pcustID=" + pcustID;
            } else {
                var url = "/quanliadmin/app/customer/customer.pscript?operFlg=2";
            }
            E.open(url, "", {height: 600,width: 980, top: 50, left: 150});
        },

        //会员修改日志
        customerLog:function( pcustID ){
            E.open("/quanliadmin/app/customer/customer.pscript?operFlg=10&pcustID=" + pcustID, "", {height: 490,width: 980, top: 50, left: 150});
        },

        //启用、禁用
        doAction: function( pcustID , useFlg ) {

            if( useFlg == 0 ) {
                var  str = '禁用';
            } else {
                var  str = '启用';
            }
            E.confirm('您确认要' + str + '会员吗？', function() {

                E.loadding.open('正在' + str + '会员，请稍候...');
                E.ajax_get({
                    url: '/invokingAjax-backend/customer/customer.ajax?operFlg=100&act=change',
                    data: {
                        pcustID: pcustID,
                        useFlg: useFlg
                    },
                    call: function( o ) {
                        E.loadding.close();
                        if (o.code == 200) {
                            E.alert(o.message, 2, "customer.load");
                        } else {
                            E.alert(o.message);
                        }
                    }
                });

            });

        },

        //账户
        customerAccount:function( pcustID ){
            E.open("/quanliadmin/app/customer/customer.pscript?operFlg=12&pcustID=" + pcustID, "", {height: 600,width: 980, top: 50, left: 150});
        },

        deliver: function( pcustID ) {
            E.open("/quanliadmin/app/customer/deliver.pscript?operFlg=1&pcustID=" + pcustID);
        },

        //mod by dongleixin 订单跳转新页面改为在本页面打开 start
        //订单
        customerBill:function( custID ){
           // window.open('/quanliadmin/app/bill/billSearch.pscript?operFlg=1&custID=' + custID);
            self.location = '/quanliadmin/app/bill/billSearch.pscript?operFlg=1&custID=' + custID;
        },
        //mod by dongleixin 订单跳转新页面改为在本页面打开 end
        //重置密码
        resetPassWord:function( pcustID , custID ){
            E.confirm("您确认要重置["+custID+"]的密码吗?<br>", function() {

                E.loadding.open('正在重置密码，请稍候...');
                E.ajax_get({
                    url: '/invokingAjax-backend/customer/customer.ajax?operFlg=100&act=reset_pwd',
                    data: {
                        pcustID: pcustID
                    },
                    call: function( o ) {
                        E.loadding.close();
                        if ( o.code == 200 ) {
                            E.alert(o.message , 2 , "customer.load");
                        } else {
                            E.alert(o.message);
                        }
                    }
                });

            });
        },
        //add by 20141104 allen.qiang FUN-BK-0019-手工重置会员密码 start
        //手工重置密码 弹窗接收密码输入
        resetPassWord1:function( pcustID , custID ){
            var html = '<div class="form-horizontal">';
            html += '<div class="form-group">';
            html += '<div class="col-sm-15">';
            html += '<label for="bindpwd1" class="col-sm-3 control-label">输入密码：</label>';
            html += '<input type="password" class="form-control w150" style="width: 200px" id="pwd_1" placeholder="输入密码" value="" ><br />';
            html += '<label for="bindpwd1" class="col-sm-3 control-label">确认密码：</label>';
            html += '<input type="password" class="form-control w150" style="width: 200px" id="pwd_2" placeholder="确认密码" value="" >';
            html += '<input type="text" name="h_pcustID" id="h_pcustID" value="' + pcustID + '"  style="display:none;"/>';
            html += '<input type="text" name="h_custID" id="h_custID" value="' + custID + '"  style="display:none;"/>';
            html += '</div>';
            html += '</div>';
           html += '</div>';

            E.popup.open({
                title: '手工重置密码',
                content: html,
                btnName: '确定',
                css: 'width: 500px;',
                btnCall: "customer.do_resetPassWord1()"//重置密码处理
            });
        },
        //手工重置密码 调用后台处理
        do_resetPassWord1:function(){

                //E.loadding.open('正在重置密码，请稍候...');

                E.ajax_get({
                    url: '/invokingAjax-backend/customer/customer.ajax?operFlg=100&act=reset_pwd1',
                    data: {
                        pcustID: $("#h_pcustID").val(),
                        pwd_1: $("#pwd_1").val(),
                        pwd_2: $("#pwd_2").val()
                    },
                    call: function( o ) {
                        E.loadding.close();
                        if ( o.code == 200 ) {
                            E.popup.close();
                            E.alert(o.message , 2 , "customer.load");
                        } else {
                            E.alert(o.message);
                        }
                    }
                });

        },
        //add by 20141104 allen.qiang FUN-BK-0019-手工重置会员密码 end
        load: function() {
            $("#flex").flexReload();
        },

        add:function() {
            E.open("/quanliadmin/app/customer/customer.pscript?operFlg=100", "", {height: 500,width: 980, top: 50, left: 150});
        }

    };


    $('#startDate').datepicker();
    $('#endDate').datepicker();

</script>

</body>
</html>